<?php
/**
 * Created by PhpStorm.
 * User: win7
 * Date: 2018/4/27
 * Time: 8:23
 */

// 命名空间
namespace app\api\controller\v1;

// 使用Validate验证参数
use app\api\validate\IDMustBePositiveInt;
use app\api\model\Banner as BannerModel;
use app\lib\exception\BannerMissException;

class Banner{
    /*
     * 获取指定$id的banner信息
     * $url /banner/:id 访问路由
     * $http get http请求
     * $id banner的id
     */
    public function getBanner($id) {
        (new IDMustBePositiveInt())->goCheck();
        // Banner模型关联BannerItem模型，BannerItem模型关联image
        $banner = BannerModel::getBannerByID($id);
        if (!$banner) {
            throw new BannerMissException();
        }
        return $banner;
    }
}